package com.suse.warmstill.transaction;

import com.suse.warmstill.common.enums.ResponseEnum;
import com.suse.warmstill.common.exception.SystemException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 使用函数式编程 + 声明式事务注解解决大事务问题
 *
 * @author Steven
 */
@Service("transactionService")
public class TransactionServiceImpl implements TransactionService {


    @Override
    @Transactional(rollbackFor = Exception.class)
    public void process(TaskTranaction runnable) {
        try {
            runnable.run();
        } catch (Exception e) {

            throw new SystemException(1111, "多事务操作失败");
        }
    }
}
